#include <stdio.h>

#define MAX 200

int c[MAX] = {0};
int M, N;

void print() {
	int i;
	for (i = 0; i < M; i++) {
		printf("%d", c[i + 1]);
	}
	printf(" ");
}
void comp(int m) {
	if (m == M + 1) {
		print();
	} else {
		for (; m <= N - M + m; m++) {
			comp(m + 1);
		}
	}
}

int main() {
	//printf("Please input M = ");
	scanf("%d", &M);
	N = 0;
	while (scanf("%d", &c[N]) != EOF) {
		N++;
	}
	//printf("N = %d, M = %d\n", N, M);

	comp(c[0]);

	return 0;
}
